package com.whlilong.jxc.sys;

import java.util.ArrayList;
import java.util.List;

import com.whlilong.jxc.db.DbManager;
import com.whlilong.jxc.model.Depart;
import com.whlilong.jxc.model.Goodsbrand;
import com.whlilong.jxc.model.Goodsinfo;
import com.whlilong.jxc.model.Hsinfo;
import com.whlilong.jxc.model.Inbasebill;
import com.whlilong.jxc.model.Iostorage;
import com.whlilong.jxc.model.Keshang;
import com.whlilong.jxc.model.Khinfo;
import com.whlilong.jxc.model.Kstype;
import com.whlilong.jxc.model.Purcharsbook;
import com.whlilong.jxc.model.Regist;
import com.whlilong.jxc.model.Selldetail;
import com.whlilong.jxc.model.Sellmain;
import com.whlilong.jxc.model.Storage;
import com.whlilong.jxc.model.Users;
import com.whlilong.jxc.model.Yginfo;
import com.whlilong.jxc.treemodel.BrandInfoTreeChildren;
import com.whlilong.jxc.treemodel.BrandInfoTreeParent;
import com.whlilong.jxc.treemodel.BusinessInfoTreeChildren;
import com.whlilong.jxc.treemodel.BusinessInfoTreeParent;
import com.whlilong.jxc.treemodel.DepartInfoTreeChildren;
import com.whlilong.jxc.treemodel.DepartInfoTreeParent;
import com.whlilong.jxc.treemodel.KeshangTreeChildren;
import com.whlilong.jxc.treemodel.KeshangTreeParent;
import com.whlilong.jxc.treemodel.MerchantTypeTreeChildren;
import com.whlilong.jxc.treemodel.MerchantTypeTreeParent;
import com.whlilong.jxc.treemodel.StaffInfoTreeChildren;
import com.whlilong.jxc.treemodel.StaffInfoTreeParent;

public class ExtentionInfo {
	
//	private List<Keshang> list = new ArrayList<Keshang>();
	
	private static ExtentionInfo single = new ExtentionInfo();
	
	private ExtentionInfo(){}
	
	public static ExtentionInfo getInstance(){
		if(single == null){
			single = new ExtentionInfo();
		}
		return single;
	}
	
	@SuppressWarnings("unchecked")
	public List getKeshanginfo() {
		// TODO Auto-generated method stub
		List<Keshang>  list = new ArrayList<Keshang>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getDistrict");
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List getKstypeinfo() {
		// TODO Auto-generated method stub
		List<Kstype> list = new ArrayList<Kstype>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getMerchantType");
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List getBusinessInfoList() {
		// TODO Auto-generated method stub
		List<Hsinfo> list = new ArrayList<Hsinfo>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.ui.geths");
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List getBrandInfo() {
		// TODO Auto-generated method stub
		List<Goodsbrand> list = new ArrayList<Goodsbrand>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.ui.getgoodsbrand");
		return list;
	}
	
	public List getClientInfoList() {
		// TODO Auto-generated method stub
		List<Khinfo> list = new ArrayList<Khinfo>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.ui.getkh");
		return list;
	}
	
	public List getGoodsInfoList() {
		// TODO Auto-generated method stub
		List<Goodsinfo> list = new ArrayList<Goodsinfo>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getGoodsInfo");
		return list;
	}
	
	
	@SuppressWarnings("unchecked")
	public List getKeshang() {
		// TODO Auto-generated method stub
		List<KeshangTreeParent> list = new ArrayList<KeshangTreeParent>();
		List result = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getDistrict");
		KeshangTreeParent ktp = null;
		String nodeName = "所有区域";
		ktp = new KeshangTreeParent(nodeName);
		for (int i = 0;i< result.size() ;i++) {
			Keshang keshang = (Keshang) result.get(i);
			KeshangTreeChildren ktc = new KeshangTreeChildren();
			ktc.setKeshang(keshang);
			ktp.add(ktc);
		}
		if (ktp != null) {
			list.add(ktp);
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List getKstype() {
		// TODO Auto-generated method stub
		List<MerchantTypeTreeParent> list = new ArrayList<MerchantTypeTreeParent>();
		List result = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getMerchantType");
		MerchantTypeTreeParent ktp = null;
		String nodeName = "所有类别";
		ktp = new MerchantTypeTreeParent(nodeName);
		for (int i = 0;i< result.size() ;i++) {
			Kstype merchantType = (Kstype) result.get(i);
			MerchantTypeTreeChildren ktc = new MerchantTypeTreeChildren();
			ktc.setKstype(merchantType);
			ktp.add(ktc);
		}
		if (ktp != null) {
			list.add(ktp);
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List getSpbrand() {
		// TODO Auto-generated method stub
		List<BrandInfoTreeParent> list = new ArrayList<BrandInfoTreeParent>();
		List result = (List)DbManager.getInstance().search("com.whlilong.jxc.ui.getgoodsbrand");
		BrandInfoTreeParent stp = null;
		String nodeName = "所有品牌";
		stp = new BrandInfoTreeParent(nodeName);
		for (int i = 0;i< result.size() ;i++) {
			Goodsbrand spbrand = (Goodsbrand) result.get(i);
			BrandInfoTreeChildren stc = new BrandInfoTreeChildren();
			stc.setGoodsbrand(spbrand);
			stp.add(stc);
		}
		if (stp != null) {
			list.add(stp);
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List getBusinessInfo() {
		// TODO Auto-generated method stub
		List<BusinessInfoTreeParent> list = new ArrayList<BusinessInfoTreeParent>();
		List result = (List)DbManager.getInstance().search("com.whlilong.jxc.ui.geths");
		BusinessInfoTreeParent stp = null;
		String nodeName = "所有货商";
		stp = new BusinessInfoTreeParent(nodeName);
		for (int i = 0;i< result.size() ;i++) {
			Hsinfo businessInfo = (Hsinfo) result.get(i);
			BusinessInfoTreeChildren stc = new BusinessInfoTreeChildren();
			stc.setHsinfo(businessInfo);
			stp.add(stc);
		}
		if (stp != null) {
			list.add(stp);
		}
		return list;
	}

	public List<Depart> getDepartInfoList() {
		List<Depart> list = new ArrayList<Depart>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.sys.getdepartinfo");
		return list;
	}
	
	public List getDepartTreeInfo() {
		List<DepartInfoTreeParent> list = new ArrayList<DepartInfoTreeParent>();
		List result = (List)DbManager.getInstance().search("com.whlilong.jxc.sys.getdepartinfo");
		DepartInfoTreeParent stp = null;
		String nodeName = "所有部门";
		stp = new DepartInfoTreeParent(nodeName);
		for (int i = 0;i< result.size() ;i++) {
			Depart depart = (Depart) result.get(i);
			DepartInfoTreeChildren stc = new DepartInfoTreeChildren();
			stc.setDepart(depart);
			stp.add(stc);
		}
		if (stp != null) {
			list.add(stp);
		}
		return list;
	}
	
	public List getStaffTreeInfo() {
		List<StaffInfoTreeParent> list = new ArrayList<StaffInfoTreeParent>();
		List result = (List)DbManager.getInstance().search("com.whlilong.jxc.sys.getstaffinfo");
		StaffInfoTreeParent stp = null;
		String nodeName = "所有员工";
		stp = new StaffInfoTreeParent(nodeName);
		for (int i = 0;i< result.size() ;i++) {
			Yginfo staff = (Yginfo) result.get(i);
			StaffInfoTreeChildren stc = new StaffInfoTreeChildren();
			stc.setStaff(staff);
			stp.add(stc);
		}
		if (stp != null) {
			list.add(stp);
		}
		return list;
	}
	public List<Yginfo> getStaffInfoList() {
		List<Yginfo> list = new ArrayList<Yginfo>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.sys.getstaffinfo");
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List getPurcharsBookInfo() {
		// TODO Auto-generated method stub
		List<Purcharsbook> list = new ArrayList<Purcharsbook>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getPurcharsBook");
		return list;
	}
	
	public List getPurcharsBookbill() {
		// TODO Auto-generated method stub
		List<Purcharsbook> list = new ArrayList<Purcharsbook>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getPurcharsBookbill");
		return list;
	}
	
	public List getInbaseinfo(){
		List<Inbasebill> list = new ArrayList<Inbasebill>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getInbasebill");
		return list;
	}
	
	public List getStorageinfo(){
		List<Storage> list = new ArrayList<Storage>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getStorage");
		return list;
	}
	
	public List getSellmain(){
		List<Sellmain> list = new ArrayList<Sellmain>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getSellmain");
		return list;
	}
	
	public List getSelldetail(){
		List<Selldetail> list = new ArrayList<Selldetail>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getSelldetail");
		return list;
	}
	public List getRegist(){
		List<Regist> list = new ArrayList<Regist>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.getRegist");
		return list;
	}
	public List getUser(){
		List<Users> list = new ArrayList<Users>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.ui.LoginDialog.getUserName");
		return list;
	}
	public List getIostorageinfo(){
		List<Iostorage> list = new ArrayList<Iostorage>();
		list = (List)DbManager.getInstance().search("com.whlilong.jxc.editor.getIostorage");
		return list;
	}
}